package com.jiantong.user.impl.service;

import com.jiantong.user.impl.dao.GovernmentUserDutyDao;
import com.jiantong.user.model.GovernmentUserDuty;
import com.jiantong.user.service.GovernmentUserDutyWriteService;
import io.terminus.boot.rpc.common.annotation.RpcProvider;
import io.terminus.common.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by ThinkPad on 2017/8/4.
 */
@Slf4j
@Service
@RpcProvider
public class GovernmentUserDutyWriteServiceImpl implements GovernmentUserDutyWriteService {


    private final GovernmentUserDutyDao governmentUserDutyDao;

    @Autowired
    public GovernmentUserDutyWriteServiceImpl(GovernmentUserDutyDao governmentUserDutyDao) {
        this.governmentUserDutyDao = governmentUserDutyDao;
    }

    @Override
   public Response<Long> add(GovernmentUserDuty governmentUserDuty) {


        try{
            governmentUserDutyDao.create(governmentUserDuty);
            return Response.ok(governmentUserDuty.getId());
        }catch (Exception e){

            return Response.fail("插入错误");
        }


    }
}
